home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 July
/
Macworld (1999-07).dmg
/
Shareware World
/
Info
/
For Developers
/
Mops 3.4.sea
/
Quick Edit ƒ
/
Subject Glossary
/
Toolbox
< prev
next >
Wrap
Text File
|
1996-01-14
|
4KB
|
112 lines
\ 14Jan96 DBH
NAMED TOOLBOX ACCESS
SYSCALL ( -- : TrapName ) ToolBox CALLSMOD.txt
Used to compile a call to a Macintosh Toolbox routine. Simply
follow syscall with the name of the routine. No need to realign
the stack as this is taken care of automatically. Execution only.
You have to "pre-declare" any system call you're going to use, outside any
definition, and before any definition in which you do the call. It doesn't
matter if you use SYSCALL several times over for the one call—in different
source files, say—subsequent ones will be ignored. The names following SYSCALL
are case-sensitive. See CALL.
CALL -- : TrapName
Used to compile a call to a Macintosh Toolbox routine. Simply follow
call with the name of the routine. Compilation only.
GLOBAL -- addr : globalname
When followed by the name of a Mac system global variable, leaves the
memory location. Example: global ticks @ returns the number of ticks
since system startup.
KONST -- n : konstName
Returns a Mac system constant. For example, konst kAEQuitApplication
will return the event id 'quit' on the stack.
STACK MANIPULATION FOR TOOLBOX CALLS
Important note for Mops 2.7. These words are no longer necessary if you
use the SYSCALL mechanism.
We need the following words to make it easy to convert our Mops stack items,
which are always 32-bit, to and from 16-bit items as required by many Mac
Toolbox calls.
I->L 16-bit-num -- 32-bit-num
Converts the 16-bit half-cell on top of stack into a full 32-bit Mops
cell, extending the sign bit. i->l is useful in handling the result
from Macintosh ROM routines that return a 16-bit signed integer on the
stack. i->l differs from Extend in that i->l pushes two bytes onto
the stack while extending the sign, whereas extend only extends the
sign of a 16-bit integer contained in the 32-bit cell on top of stack,
converting it into a 32-bit signed integer. Word0, a related word,
pushes two zero bytes onto the stack.
MAKEINT 32-bit-num -- 16-bit-num
Drops the higher 16 bits of the number on top of the stack. This is
handy in Toolbox calls that require an Int value.
W -- 16-bit-value : value
Useful for compiling a 16 bit number for toolbox calls. Same as n
makeint except n must be known at compilation time. More compact than
using n makeint.
WORD0 n -- 16-zero-bits
Pushes 16 zero bits (hex 0000) onto the stack. You can use word0 to
prepare for a Toolbox function call for the result, if the function
returns a Toolbox integer.
TBOOL b -- tbool
Makes a Mops boolean into a Toolbox boolean. Note that tbool should
only be used as a setup for a Toolbox call as the stack will be
mis-aligned until the Toolbox call is done.
PACK x y -- x:y
Packs two 32-bit numbers into one 32-bit number. Only the lower 16
bits of x and y are used. You can use pack to convert a coordinate
point into a Toolbox-compatible point.
UNPACK x:y -- x y
Unpacks a Toolbox point and puts the two integers on the stack.
Unpack is the opposite of pack.
MISCELLANEOUS
STR255 addr len -- ^buf255
Converts text beginning at addr for len characters to a str255 type
string at buf255, leaving the addr of buf255. Note that you should use
the string right away as the next call to str255 will overwrite the
buffer.
:PROC -- : name
Begins compilation of a word that to the Toolbox behaves like a Pascal
procedure or function. You can use a :proc word when a Toolbox
routine requires a procedural argument.
;PROC --
Ends compilation of word defined with :proc
'TYPE -- 4bytestring : XXXX
Given 4 ascii characters in the input stream, a 4bytestring will
be left on the stack. This data type is also known as a PACKED
ARRAY[1..4] OF CHAR; in Pascal.
TRAP$ -- : trap#
Compiles a toolbox trap if the Tools module is not loaded. The new
syntax is, e.g.trap$ A9FF
FDOS$ -- : trap#
Compiles a toolbox trap for I/O if the Tools module is not loaded.
The new syntax is, e.g.trap$ fdos$ A000